package cn.kgc.jinxin.clothesstore.dao.impl;

import java.sql.*;

import cn.kgc.jinxin.clothesstore.dao.BaseDao;
import cn.kgc.jinxin.clothesstore.dao.OrderDetailDao;
import cn.kgc.jinxin.clothesstore.entity.OrderDetail;

public class OrderDetailDaoImpl implements OrderDetailDao {

	@Override
	public void insert(OrderDetail orderDetail, Connection connection) throws Exception {
		PreparedStatement psm = null;
		try {
			String sql = "insert into orderdetail values (?,?,?,?,?,?)";
			psm = connection.prepareStatement(sql);
			psm.setLong(1, orderDetail.getOrder().getOrderId());
			psm.setString(2, orderDetail.getGoods().getGoodsId());
			psm.setInt(3, orderDetail.getOrderNum());
			psm.setString(4, orderDetail.getGoodsName());
			psm.setDouble(5, orderDetail.getGoodsPrice());
			psm.setDouble(6, orderDetail.getSubPrice());
			psm.executeUpdate();
		} finally {
			BaseDao.close(null, psm, null);
		}
		
		

	}

}
